package com.sc.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sc.domain.Hire;
import com.sc.dto.HireDTO;
import com.sc.mapper.HireMapper;
import com.sc.service.HireService;
import com.sc.vo.HireVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class HireServiceImpl implements HireService {

    @Autowired
    private HireMapper hireMapper;

    @Override
    public boolean add(Hire hire) {
        return hireMapper.add(hire);
    }

    @Override
    public Map<String, Object> pageQuery(HireDTO hireDTO) {
        PageHelper.startPage(hireDTO.getPageNum(), hireDTO.getPageSize());
        Page<HireVO> hireVOPage = hireMapper.pageQuery(hireDTO);
        Map<String, Object> map = new HashMap<>();
        map.put("total", hireVOPage.getTotal());
        map.put("pageSize", hireVOPage.getPageSize());
        map.put("pageNumber", hireVOPage.getPageNum());
        map.put("data", hireVOPage.getResult());
        return map;
    }

    @Override
    public Hire selectById(Integer id) {
        return hireMapper.selectById(id);
    }

    @Override
    public boolean update(Hire hire) {
        return hireMapper.update(hire);
    }

    @Override
    public boolean deleteById(Integer id) {
        return hireMapper.deleteById(id);
    }

    @Override
    public boolean deleteByIds(List<Integer> ids) {
        return hireMapper.deleteByIds(ids);
    }
}
